package cmo.neutech.day15;

public class ticket {
    public static int tickets = 100;
    public synchronized void A(){
        if(tickets > 0){
            System.out.println("A售出一张票");
            tickets--;
        }
    }

    public synchronized void B(){
        if(tickets > 0){
            System.out.println("B售出一张票");
            tickets--;
        }
    }

    public static void main(String[] args) {
        while (tickets > 0){
            ticket t = new ticket();
            t.A();
            t.B();
        }
    }
}
